package com.feonix.blockchain.pojo;

import java.io.Serializable;
import java.util.List;

/**
 * 区块类
 */
public class Block implements Serializable {
    /**
     * 索引
     */
    private int index;
    /**
     * 时间戳
     */
    private long timestamp;
    /**
     * 交易列表
     */
    private List<Transaction> transactions;
    /**
     * 工作量证明
     */
    private long proof;
    /**
     * 前一个区块的哈希值
     */
    private String previous_hash;

    public Block() {
    }

    public Block(int index, long timestamp, List<Transaction> transactions, long proof, String previous_hash) {
        this.index = index;
        this.timestamp = timestamp;
        this.transactions = transactions;
        this.proof = proof;
        this.previous_hash = previous_hash;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public List<Transaction> getTransactions() {
        return transactions;
    }

    public void setTransactions(List<Transaction> transactions) {
        this.transactions = transactions;
    }

    public long getProof() {
        return proof;
    }

    public void setProof(long proof) {
        this.proof = proof;
    }

    public String getPrevious_hash() {
        return previous_hash;
    }

    public void setPrevious_hash(String previous_hash) {
        this.previous_hash = previous_hash;
    }

    @Override
    public String toString() {
        return "Block{" +
                "index=" + index +
                ", timestamp=" + timestamp +
                ", transactions=" + transactions +
                ", proof=" + proof +
                ", previous_hash='" + previous_hash + '\'' +
                '}';
    }
}
